package com.md.drcs.dicom.dao;

import com.md.common.utils.dao.MyMapper;
import com.md.drcs.dicom.entity.DiskEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface DiskDao extends MyMapper<DiskEntity> {

    @Select("select * from t_disk where is_actived = 1 limit 0, 1")
    DiskEntity getCurrentActivedDisk();

    @Select("select * from t_disk order by free_space desc limit 0, 1")
    DiskEntity getMaxFreeSpaceDisk();

    @Update("update t_disk set is_actived = 1, update_time = now() where `code` = #{code}")
    void activeDisk(String code);

    @Update("update t_disk set is_actived = 0, update_time = now() where is_actived = 1")
    void stopUsingDisk();

    @Update("update t_disk set used_space = #{usedSpace}, update_time = now() where `code` = #{code}")
    void updateDiskUsedSpace(@Param("code") String code, @Param("usedSpace") Integer usedSpace);

}
